import QRequest from '@/service/index';
import type { QsRequestHeaderType } from '@/service/request/type';

import type { WorkshopListParams, WorkshopListResponse, AddWorkshopBody } from './model/type';

/**
 * @: 获取车间列表
 * @param {WorkshopListParams} params
 * @return {*}
 */
export const doGetWorkshopList = (
    params: WorkshopListParams,
    hideLoading: QsRequestHeaderType['hideLoading'] = 0
) => {
    return QRequest.get<WorkshopListResponse>(`/workshop/list`, {
        params,
        headers: {
            hideLoading
        }
    });
};

/**
 * @: 新增车间列表
 * @param {AddWorkshopBody} data
 * @return {*}
 */
export const doAddWorkshop = (data: AddWorkshopBody) => {
    return QRequest.post(`/workshop/save`, data, {
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @: 编辑车间列表
 * @param {AddWorkshopBody} data
 * @return {*}
 */
export const doUpdateWorkshop = (data: AddWorkshopBody) => {
    return QRequest.put(`/workshop/update`, data, {
        headers: {
            hideLoading: 1
        }
    });
};
